#version 460



layout(std140, set=0, binding=0) uniform U_Matrix {
	mat4 mat_ProjecView;
	//mat4 mat_view;	
};

//layout(std140, set=1, binding=1) uniform mat4 Model_Matrix;
layout(std140, binding = 1) readonly buffer U1_Matrix {
	mat4 mat_Model[];
};



layout(location = 0) in vec3 inPos;
layout(location = 1) in uint inColor;


layout(location = 0) out vec4 vColor;
out gl_PerVertex {
	vec4	gl_Position;
	float	gl_PointSize;
};






vec4 f_buildColor(in uint color){
	vec4 TColor;
	TColor.r = float((color & 0xff000000) >> 24) / 255.0;
	TColor.g = float((color & 0x00ff0000) >> 16) / 255.0;
	TColor.b = float((color & 0x0000ff00) >> 8) / 255.0;
	TColor.a = float((color & 0x000000ff)) / 255.0;

	return TColor;
}



void main(void) {
	vec4 p = vec4(inPos, 1.0);
	gl_Position = mat_ProjecView * mat_Model[gl_InstanceIndex] * p;
	//gl_Position = vec4(inPos, 1.0);
	vColor = f_buildColor(inColor);

	if(gl_VertexIndex < 3){
		//gl_Position = mat_ProjecView * vec4(vs[gl_VertexIndex], 1.0);
		//gl_Position = vec4(vs[gl_VertexIndex], 1.0);
	}
	//gl_Position = vec4(vs[gl_VertexIndex], 1.0);
	gl_PointSize = 2.0;
}


